using System.Collections.Generic;

namespace Ioc.Kernel.Selectors
{
    public class ParameterSelector : IParameterSelector
    {
        private readonly IList<Parameter> parameters;

        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterSelector"/> class.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        public ParameterSelector(IList<Parameter> parameters)
        {
            this.parameters = parameters;
        }

        #region IParameterSelector Members

        /// <summary>
        /// Selects the parameter.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public Parameter SelectParameter(string name)
        {
            foreach (Parameter parameter in parameters)
            {
                if (parameter.Name == name)
                    return parameter;
            }
            return null;
        }

        #endregion
    }
}